home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
WINSRC20.ZIP
/
WINFRACT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-22
|
44KB
|
1,195 lines
/****************************************************************************
PROGRAM: winfract.c
PURPOSE: Windows-specific main-driver code for Fractint for Windows
(look in MAINFRAC.C for the non-windows-specific code)
Copyright (C) 1990 The Stone Soup Group. Fractint for Windows
may be freely copied and distributed, but may not be sold.
We are, of course, copyrighting the code we wrote to implement
Fractint-for-Windows, and not the routines we lifted directly
or indirectly from Microsoft's Windows 3.0 Software Development Kit.
****************************************************************************/
#include "windows.h"
#include "winfract.h"
#include "fractype.h"
#include "fractint.h"
#include "select.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <search.h>
#include <string.h>
#include <time.h>
LPSTR win_lpCmdLine;
HANDLE hInst;
HWND hwnd; /* handle to main window */
HWND hWndCopy; /* Copy of hWnd */
#define PALETTESIZE 256 /* dull-normal VGA */
HANDLE hpal; /* palette handle */
PAINTSTRUCT ps; /* paint structure */
HDC hDC; /* handle to device context */
HDC hMemoryDC; /* handle to memory device context */
BITMAP Bitmap; /* bitmap structure */
HANDLE hPal; /* Handle to the application's logical palette */
HANDLE hLogPal; /* Temporary Handle */
LPLOGPALETTE pLogPal; /* pointer to tha application's logical palette */
int iNumColors; /* Number of colors supported by device */
int iRasterCaps; /* Raster capabilities */
int iPalSize; /* Size of Physical palette */
BOOL win_systempaletteused = FALSE; /* flag system palette set */
extern int win_syscolorindex[21];
extern DWORD win_syscolorold[21];
extern DWORD win_syscolornew[21];
#define EXE_NAME_MAX_SIZE 128
BOOL bHelp = FALSE; /* Help mode flag; TRUE = "ON"*/
HCURSOR hHelpCursor; /* Cursor displayed when in help mode*/
char szHelpFileName[EXE_NAME_MAX_SIZE+1]; /* Help file name*/
void MakeHelpPathName(char*); /* Function deriving help file path */
unsigned char far win_dacbox[256][3];
extern unsigned char dacbox[256][3];
BOOL bTrack = FALSE; /* TRUE if user is selecting a region */
BOOL zoomflag = FALSE; /* TRUE is a zoom-box selected */
RECT Rect;
int Shape = SL_BLOCK; /* shape to use for the selection rectangle */
/* pointers to various dialog-box routines */
FARPROC lpProcAbout;
FARPROC lpOpenDlg;
FARPROC lpSelectFractal;
FARPROC lpSelectFracParams;
FARPROC lpSelectImage;
FARPROC lpSelectDoodads;
FARPROC lpSelectCycle;
FARPROC lpSaveAsDlg;
FARPROC lpProcStatus;
FARPROC lpSelect3D;
FARPROC lpSelect3DPlanar;
FARPROC lpSelect3DSpherical;
extern unsigned char readname[], FileName[], FormFileName[];
extern unsigned char DialogTitle[], DefSpec[], DefExt[];
HBITMAP hBitmap, oldBitmap, oldoldbitmap; /* working bitmaps */
HANDLE hDibInfo; /* handle to the Device-independent bitmap */
LPBITMAPINFO pDibInfo; /* pointer to the DIB info */
int far *palette_values; /* pointer to palette values */
HANDLE hpixels; /* handle to the DIB pixels */
unsigned char huge *pixels; /* the device-independent bitmap pixels */
extern int bytes_per_pixelline; /* pixels/line / pixels/byte */
int last_written_y = -2; /* last line written */
int screen_to_be_cleared = 1; /* flag that the screen is to be cleared */
int time_to_act = 0; /* time to take some sort of action? */
int time_to_restart = 0; /* time to restart? */
int time_to_reinit = 0; /* time to reinitialize? */
int time_to_quit = 0; /* time to quit? */
int time_to_save = 0; /* time to save the file? */
int time_to_print = 0; /* time to print the file? */
int time_to_load = 0; /* time to load a new file? */
int time_to_cycle = 0; /* time to begin color-cycling? */
int win_3dspherical = 0; /* spherical 3D? */
int win_display3d, win_overlay3d; /* 3D flags */
extern int win_cycledir, win_cyclerand;
extern int calc_status;
int xdots, ydots, colors, maxiter;
int ytop, ybottom, xleft, xright;
int xposition, yposition, win_xoffset, win_yoffset, xpagesize, ypagesize;
int win_xdots, win_ydots;
extern int fractype;
extern double param[4];
extern double xxmin, xxmax, yymin, yymax, xx3rd, yy3rd;
double jxxmin, jxxmax, jyymin, jyymax, jxx3rd, jyy3rd;
extern int frommandel, bitshift, biomorph;
extern char str[255];
int cpu, fpu; /* cpu, fpu flags */
extern int win_release;
char *win_choices[100];
int win_numchoices, win_choicemade;
extern int onthelist[];
extern int CountFractalList;
extern int CurrentFractal;
char FormNameChoices[41][21];
char FormName[30];
extern char ifsfilename[]; /* IFS code file */
extern char ifs3dfilename[]; /* IFS 3D code file */
/****************************************************************************
FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
PURPOSE: calls initialization function, processes message loop
****************************************************************************/
int PASCAL WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
HANDLE hInstance;
HANDLE hPrevInstance;
LPSTR lpCmdLine;
int nCmdShow;
{
int Return;
win_lpCmdLine = lpCmdLine;
if (!hPrevInstance)
if (!InitApplication(hInstance))
return (FALSE);
if (!InitInstance(hInstance, nCmdShow))
return (FALSE);
fractint_main(); /* fire up the main Fractint code */
DestroyWindow(hWndCopy); /* stop everything when it returns */
return(0); /* we done when 'fractint_main' returns */
}
/****************************************************************************
FUNCTION: InitApplication(HANDLE)
PURPOSE: Initializes window data and registers window class
****************************************************************************/
BOOL InitApplication(hInstance)
HANDLE hInstance;
{
WNDCLASS wc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, "FracIcon");
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = "WinFracMenu";
wc.lpszClassName = "FractintForWindowsV0010";
return (RegisterClass(&wc));
}
/****************************************************************************
FUNCTION: InitInstance(HANDLE, int)
PURPOSE: Saves instance handle and creates main window
****************************************************************************/
BOOL InitInstance(hInstance, nCmdShow)
HANDLE hInstance;
int nCmdShow;
{
DWORD WinFlags;
WORD DeviceCaps;
int iLoop, jLoop;
DWORD ThisColor;
float temp;
char tempname[40];
/* so, what kind of a computer are we on, anyway? */
WinFlags = GetWinFlags();
cpu = 88; /* determine the CPU type */
if (WinFlags & WF_CPU186) cpu = 186;
if (WinFlags & WF_CPU286) cpu = 286;
if (WinFlags & WF_CPU386) cpu = 386;
if (WinFlags & WF_CPU486) cpu = 386;
fpu = 0; /* determine the FPU type */
if (WinFlags & WF_80x87) fpu = 87;
if (WinFlags & WF_CPU486) fpu = 387;
hInst = hInstance;
temp = win_release / 100.0;
sprintf(tempname,"Fractint for Windows - Vers %5.2f", temp);
hwnd = CreateWindow(
"FractintForWindowsV0010",
tempname,
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
160, 1